package com.sodaopen.study.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import com.sodaopen.study.entity.Locked;

import java.util.List;

public interface LockedMapper {
    @Select("select o.user_id, o.course_id, o.chapter_id, u.name, c.name course_name, p.name chapter_name, o.created_date" +
            " from t_locked o, t_course c, t_chapter p, t_user u where o.user_id=u.id" +
            " and o.course_id=c.id and o.chapter_id=p.id")
    List<Locked> selectAll();

    @Delete("delete from t_locked where user_id=#{userId} and course_id=#{courseId}")
    void deleteUserLocked(Integer userId, Integer courseId);
}
